package com.beijing.cyou.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.beijing.cyou.model.SMSBalance;
import com.beijing.cyou.params.SMSParams;
import com.beijing.cyou.service.SMSBalanceService;
import com.beijing.cyou.utils.NotNullHelps;

@Slf4j
@RestController
@Api(value = "SMS-controller", description = "SMS帮助API")
public class SMSBalanceController {

	@Autowired
	private SMSBalanceService balanceService ;
	
	private String message ;
	
	@ResponseBody
	@RequestMapping("/{id}/showSMS")
	@ApiOperation(value = "查询SMS详情" , notes = "由id查询", httpMethod = "GET")
	public SMSBalance showSMSInfo(@PathVariable Long id) {
		SMSBalance balance = null ;
		if (NotNullHelps.isNotNull(id) == false) {
			message = ")))) 数据有误！ ((((" ;
		}else {
			balance = balanceService.getSMSInfoById(id);
			message = "#### success - showSMSInfo  @@@";
		}
		log.info(message);
		return balance ;
		
	}
	
	@ResponseBody
	@RequestMapping("/getSMSInfoList")
	@ApiOperation(value = "SMS列表" , notes = "由balance查询", httpMethod = "GET")
	public List<SMSBalance> reachSMSInfoListByBalance(@RequestParam(value = "balance", required = true) Integer balance){
		SMSParams condition = new SMSParams(balance);
		List<SMSBalance> balanceList = balanceService.listSMSInfoList(condition) ;
		if (NotNullHelps.isNotNull(balance) == false) {
			message = "## 参数不全！ @@" ;
		}else {
			message = NotNullHelps.isNotNull(balanceList) == false 
			 ? "&& balance-没有数据呦！ @@" : "## balanceList 查询成功！ @@";
		}
		log.info(message);
		return balanceList ;
	}
	
	
}
